package com.joke.mydiary.pickers;

import android.app.Dialog;
import android.app.DialogFragment;
import android.app.TimePickerDialog;
import android.content.DialogInterface;
import android.os.Bundle;


import com.joke.mydiary.RemindManagerActivity;

import java.util.Calendar;

/**
 * 选择时间对话框
 * Created by Administrator on 2015/12/2.
 */
public class TimePickerFragment extends DialogFragment {

    private RemindManagerActivity remindActivity;

    public static TimePickerFragment getTimePickerFragmet(RemindManagerActivity remindActivity) {
        TimePickerFragment tpf = new TimePickerFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("remindActivity", remindActivity);
        tpf.setArguments(bundle);
        return tpf;
    }


    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        final Calendar c = Calendar.getInstance();
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int minute = c.get(Calendar.MINUTE);
        remindActivity = (RemindManagerActivity) this.getArguments().getSerializable("remindActivity");
        // Create a new instance of TimePickerDialog and return it
        return new TimePickerDialog(getActivity(), remindActivity, hour, minute,true);

    }

    @Override
    public void onCancel(DialogInterface dialog) {
        remindActivity.cancelMessage();
        super.onCancel(dialog);
    }
}
